<!--
Date: 2025-08-13
Copyright (c) 2025 Industrial Software Feature Database
-->
<template>
  <div class="material-main">
    <MaterialIndex v-if="showIndex" databaseName="紧固件库" :currentChooseId="currentChooseId" @handleEvent="handleEvent" />
    <MaterialPage v-if="showPage" :tableName="tableName" :currentChooseId="currentChooseId" :fieldList="fieldList" :row="rowData" @handleEvent="handleEvent" />
  </div>
</template>
<script setup>
import MaterialIndex from './component/MaterialIndex.vue';
import MaterialPage from './component/MaterialPage.vue';
const showIndex = ref(true);
const showPage = ref(false);
const rowData = ref(null);
const fieldList = ref(null);
const currentChooseId = ref('');
const tableName = ref('');
const handleEvent = (data) => {
  if (data.component === 'Index') {
    rowData.value = data.row ? data.row : null;
    showIndex.value = true;
    showPage.value = false;
  }
  if (data.component === 'Page') {
    rowData.value = data?.row || null;
    tableName.value = data?.tableName;
    fieldList.value = data?.fieldList || [];
    currentChooseId.value = data?.currentChooseId || null;
    showIndex.value = false;
    showPage.value = true;
  }
};
</script>
<style lang="scss" scoped>
.material-main {
  height: calc(100vh - 84px);
  width: 100%;
}
</style>
